package com.example.demo.exception;

/**
 * 错误码
 * @author chen huilong
 * @since 2022-10-04
 */
public enum ErrorCode implements ReplyInfo {

    SUCCESS(200, "成功"),
    BAD_REQUEST(400, "请求参数有误"),
    BAD_FORMAT(400, "请求参数类型错误"),
    INTERNAL_SERVER_ERROR(500, "服务器出错"),
    DATA_BASE_EXCEPTION(500, "数据库操作出错"),

    /** 通用业务错误码 */
    INCOMPLETE_PARAMETER(401, "请求参数不全"),
    REDIS_CONNECTION_ERROR(500, "Redis连接异常"),
    REQUIRE_SUPER_MANAGER(403, "该操作需要超级管理员权限"),
    METHOD_NOT_SUPPORTED(500, "该接口不支持此类型请求"),

    /** 用户模块业务错误码 */
    TOKEN_NOT_EXISTED(400, "请求缺少token参数"),
    NOT_LOGIN(403, "尚未登录"),
    CACHE_IS_EXPIRED(402, "缓存已过期，请重新登陆"),
    USERNAME_IS_NULL(400, "用户名为空"),
    PASSWORD_IS_NULL(401, "密码为空"),
    NO_SUCH_USER(402, "该用户不存在"),
    WRONG_ACCOUNT_OR_PASSWORD(403, "帐号或密码错误"),

    WRONG_GENDER(400, "性别错误"),

    /**
     * 好友组队模块
     */
    VERIFICATION_CODE_LENGTH_WRONG(400, "验证码长度错误"),
    USER_NUMBER_IS_NULL(401, "学号为空"),
    VERIFICATION_CODE_IS_NULL(402, "验证码为空"),
    PEOPLE_COUNT_GREATER_FOUR(403, "队伍已满"),
    VERIFICATION_CODE_WRONG(404, "验证码错误"),
    GENDER_WRONG(405, "性别出错"),
    PART_IN_OTHER_GROUP(406, "已加入其他组"),


    USER_DO_NOT_HAVE_ROOM(400, "暂无宿舍"),

    SESSION_IS_EXPIRED(400, "会话已过期，请重新登录"),
    INPUT_TWO_PASSWORD_IS_DIFF(402, "两次密码不同，修改失败"),
    OLD_PASSWORD_IS_WRONG(403, "原密码错误，修改失败"),


    /**
     * 订单模块
     */
    QUANTITY_NOT_ENOUGH(401, "床位数量不足，订单无效"),
    HAVE_ROOM(402, "已有宿舍，下单失败"),
    WRONG_BUILDING_ID(403, "错误宿舍楼编号")

    ;


    private int code;

    private String msg;

    ErrorCode(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }
}
